﻿package plugin.map.ui
{
    import com.core.*;
    import com.sh.game.util.*;
    import consts.*;
    import flash.display.*;
    import flash.utils.*;
    import morn.core.components.*;

    public class ActorPoint extends Object
    {
        private var _container:DisplayObjectContainer;
        private var _type:int = 0;
        public var gameObj:Object;
        private var _realX:Number = 0;
        private var _realY:Number = 0;
        public var role:UrlImage;
        private var _dir:int = -1;
        private const _url1:String = "cs2_mapasset/";
        private const _url2:String = ".png";
        private var txt:Label;

        public function ActorPoint(param1:DisplayObjectContainer, param2:Object)
        {
            var _loc_3:int = 0;
            var _loc_4:int = 0;
            var _loc_5:int = 0;
            this._container = param1;
            this.gameObj = param2.gameObj.baseObj;
            if (param2.gameObj.baseObj.type == ActorType.Actor || param2.gameObj.baseObj.type == ActorType.Monster || param2.gameObj.baseObj.type == ActorType.BOSS || param2.gameObj.baseObj.type == ActorType.BigMonster)
            {
                if (param2.isMe())
                {
                    this._dir = param2.dir;
                    this.role = new UrlImage();
                    this.role.url = this._url1 + "own_point" + this._url2;
                    this.role.pivotX = int(this.role.width * 0.5);
                    this.role.pivotY = int(this.role.height * 0.5);
                    param1.addChild(this.role);
                    this.dir = param2.dir;
                }
                else if (param2.mine || param2.hasOwnProperty("teamid") && param2.teamid == UserData.getUserData("teamid"))
                {
                    this.role = new UrlImage();
                    this.role.url = this._url1 + "green_point" + this._url2;
                    this.role.pivotX = int(this.role.width * 0.5);
                    this.role.pivotY = int(this.role.height * 0.5);
                    param1.addChildAt(this.role, 0);
                }
                else
                {
                    this.role = new UrlImage();
                    this.role.url = this._url1 + "red_point" + this._url2;
                    this.role.pivotX = int(this.role.width * 0.5);
                    this.role.pivotY = int(this.role.height * 0.5);
                    param1.addChildAt(this.role, 0);
                }
                this.x = this.x;
                this.y = this.y;
            }
            else
            {
                this.role = new UrlImage();
                this.role.pivotX = int(this.role.width * 0.5);
                this.role.pivotY = int(this.role.height * 0.5);
                if (param2.gameObj.baseObj.model == "5060")
                {
                    this.role.url = this._url1 + "tom" + this._url2;
                    this.txt = new Label();
                    _loc_3 = param2.gameObj.baseObj.fuckTime;
                    _loc_4 = Number(ModelProxy.getValue("data", "servertime") + getTimer()) / 1000;
                    _loc_5 = _loc_3 - _loc_4;
                    this.txt.text = param2.gameObj.baseObj.name + "\n复活时间:" + TimeDataFormatUtil.getLeftTime2(_loc_5);
                    this.txt.width = 200;
                    this.txt.multiline = true;
                    this.txt.align = "center";
                    this.txt.wordWrap = true;
                    this.txt.leading = 4;
                    this.txt.color = "0xffffff";
                    this.txt.stroke = "0x0";
                    param1.addChild(this.txt);
                    param1.mouseEnabled = false;
                    param1.mouseChildren = false;
                }
                else
                {
                    this.role.url = this._url1 + "green_point" + this._url2;
                }
                param1.addChildAt(this.role, 0);
            }
            this.role.x = -int(this.role.width * 0.5);
            this.role.y = -22;
            return;
        }// end function

        public function get dir() : int
        {
            return this._dir;
        }// end function

        public function set dir(param1:int) : void
        {
            this._dir = param1;
            if (this.role)
            {
                this.role.rotation = this._dir * 45;
            }
            return;
        }// end function

        public function set x(param1:Number) : void
        {
            this._realX = param1;
            if (this.role)
            {
                this.role.x = int(param1);
            }
            if (this.txt)
            {
                this.txt.x = int(param1) - 85;
            }
            return;
        }// end function

        public function get x() : Number
        {
            return this._realX;
        }// end function

        public function get y() : Number
        {
            return this._realY;
        }// end function

        public function set y(param1:Number) : void
        {
            this._realY = param1;
            if (this.role)
            {
                this.role.y = int(param1);
            }
            if (this.txt)
            {
                this.txt.y = int(param1) + 20;
            }
            return;
        }// end function

        public function dispose() : void
        {
            if (this.role && this.role.parent)
            {
                this.role.parent.removeChild(this.role);
            }
            if (this.txt && this.txt.parent)
            {
                this.txt.parent.removeChild(this.txt);
            }
            this.gameObj = null;
            this._container = null;
            return;
        }// end function

    }
}
